// run: $exec < input
#include <iostream>

int a[2000];
int n;

int main()
{
	while (std::cin >> n) {
		for (int i = 1; i <= n; i++) std::cin >> a[i];
		int tot = 0;
		for (int i = 1; i <= n; i++)
			for (int j = i + 1; j <= n; j++)
				if (a[i] == a[j] + 1 || a[i] + 1 == a[j]) tot++;
		std::cout << tot << "\n";
	}
}

